package action;

import dao.BookDao;
import po.Book;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
@WebServlet(urlPatterns = "/user/action/AllBookServlet")
public class AllBookServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        BookDao bookDao = new BookDao();
        ArrayList<Book> books = bookDao.selectAll();
        //绑定数据
        req.setAttribute("books",books);
        //跳转到主页 重定向 转发 超链接 form表单
        //重定向两次请求，不涉及数据，转发一次请求，过程涉及数据
        req.getRequestDispatcher("../page/index.jsp").forward(req,resp);
    }
}
